﻿using System;
using System.Web;
using System.Web.UI;
using Auth;

public partial class admin_MasterPage : System.Web.UI.MasterPage
{
    public NoapAuth NoapAuth = new NoapAuth();

    public int UserID;

    public string Role;

    public string[] ProfileArr;

    protected void Page_Load(object sender, EventArgs e)
    {
        NoapAuth.UserIdentification();
        // 登录认证

        Page.DataBind();
    }

    public admin_MasterPage()
    {
        UserID = NoapAuth.UserID;

        Role = NoapAuth.Role;

        ProfileArr = NoapAuth.Profile;
    }

    // 权限控制
    public void OnlyAdmin()
    {
        if (Role != "administrator")
        {
            HttpContext.Current.Response.Redirect("~/403.html");
        }
    }
    
    // 登出
    protected void logout(object sender, EventArgs e)
    {
        NoapAuth.Logout();
        Response.Redirect("~/account/Login.aspx");
    }

    protected void Search(object sender, EventArgs e)
    {
        string str = TextBox1.Text.ToString().Trim();
        if (str != "")
        {
            Response.Redirect("~/admin/NewsAdmin/Search.aspx?search=" + str);
        }
    }
}
